package shoozhoo.libandrotranslationsample;

import java.util.ArrayList;

import shoozhoo.libandrotranslation.TranslationListActivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class SampleActivity extends Activity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		TextView msgTextView = (TextView)findViewById(R.id.msg);
		msgTextView.setText(getString(R.string.msg, 123, 789));
	}

	private static final int MENU_TRANSLATION = Menu.FIRST + 1;
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		menu.add(0, MENU_TRANSLATION, 1, R.string.menu_translation).setIcon(R.drawable.libandrotranslation_icon);
		return true;
	}

	@Override
    public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case MENU_TRANSLATION:
			onTranslationMenu();
			break;
		}
		return true;
	}

	private void onTranslationMenu(){
		Intent intent = new Intent(this, TranslationListActivity.class);
		intent.putExtra(TranslationListActivity.INTENT_EXTRA_MAIL_TO, "shoozhoo+LibAndroTranslationSample@gmail.com");
		intent.putExtra(TranslationListActivity.INTENT_EXTRA_MAIL_APPNAME, "LibAndroTranslationSample");
		ArrayList<String> ignores = new ArrayList<String>();
		ignores.add("app_name");
		ignores.add("no_i18n.+");
		intent.putExtra(TranslationListActivity.INTENT_EXTRA_IGNORE_PATTERNS, ignores);
		this.startActivity(intent);
	}
}